package main

import (
	"fmt"
	"math"
)

func main() {
	fmt.Println(Say("World"))
	fmt.Println(Divide(5, 2))
	fmt.Println(Sum(1, 2, 3, 4, 5))
	nums := []int{1, 2, 3, 4, 5}
	sum := Sum(nums...)
	fmt.Println(sum)
}

func Say(s string) (phrase string) {
	phrase = "Hello " + s
	return // 这里不需要显式返回变量
}

func Divide(x, y float64) (float64, float64) {
	// 截断取整 2.5 -> 2
	q := math.Trunc(x / y)
	// 取余数 5%2 效果一样
	r := math.Mod(x, y)
	return q, r
}

func Sum(x ...int) int {
	sum := 0
	for _, v := range x {
		sum += v
	}
	return sum
}
